Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): switch to generated fetch API stub #64

Merged
merged 1 commit into from
Jan 23, 2024
Merged

feat(v2): switch to generated fetch API stub #64

merged 1 commit into from
Jan 23, 2024

Conversation

pilartomas
Copy link
Collaborator

@pilartomas pilartomas commented Nov 27, 2023

This PR kicks off implementation of v2 client by establishing a new, long-lived branch and reworking the way API requests are made. Note that the overall design decision is to make the client thinner.

Below is the list of the most important changes:

  • axios is replaced by cross-fetch wrapped with strongly-typed API client stub generated from the OpenAPI schema
  • Caching is done internally by the fetch API, driven by HTTP headers
  • Retry functionality is now provided by fetch-retry, promise-retry wasn't really pluggable into the stub system.
  • Errors have been reworked. Namely RequestError has been made abstract. New, more specific, NetworkErrorhas been added and RequestCanceledError has been removed entirely as the user supplying the AbortSignal should be able to handle the abort error.
  • API types are no longer exported, OpenAPI schema is a superior replacement.
  • Client types are no longer exported, users are advised to use typescript type utilities to extract them (e.g. Parameters<typeof client.models>, Awaited<ReturnType<typeof client.models>>). We are open to reintroducing them if this proves to be insufficient.
  • Support for Node v16 has been dropped, we're now targeting v18.12.0 and higher. This is to properly support Lanchain and Fetch utilities in the generated code. Note that we could still make it work with Node v16 if there will be complaints from users.
  • zod schemas have been dropped as it's maintenance would require huge effort and it would duplicate type generation.

@pilartomas pilartomas force-pushed the v2 branch 2 times, most recently from 80effcc to 03ef7c6 Compare November 27, 2023 15:42
@pilartomas pilartomas force-pushed the v2 branch 2 times, most recently from 435f876 to a6210e3 Compare December 19, 2023 10:25
@pilartomas pilartomas requested a review from Tomas2D December 19, 2023 10:27
@pilartomas pilartomas marked this pull request as ready for review December 19, 2023 10:27
.nvmrc Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/api/client.ts Outdated Show resolved Hide resolved
src/api/event-client.ts Outdated Show resolved Hide resolved
src/utils/errors.ts Show resolved Hide resolved
src/api/client.ts Outdated Show resolved Hide resolved
src/api/event-client.ts Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Member

@Tomas2D Tomas2D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly fix the warnings / errors from pipelines.

@Tomas2D
Copy link
Member

Tomas2D commented Jan 19, 2024

ping @pilartomas

@pilartomas
Copy link
Collaborator Author

pilartomas commented Jan 21, 2024

Almost all the client functionality is yet to be added in the followup PR. Fixing the pipelines really means removing most of the tests and examples. I wanted to avoid this given they are likely to be reintroduced in that PR. Do you really want them out?

@Tomas2D
Copy link
Member

Tomas2D commented Jan 22, 2024

I see, then what about changing the target brain from main to v2-release?

@pilartomas pilartomas changed the base branch from main to v2-release January 23, 2024 11:25
@pilartomas pilartomas requested a review from Tomas2D January 23, 2024 11:25
@Tomas2D Tomas2D merged commit e88489e into v2-release Jan 23, 2024
1 of 8 checks passed
@Tomas2D Tomas2D deleted the v2 branch January 23, 2024 11:27
pilartomas added a commit that referenced this pull request Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants